#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>

const static int num = 10;
int main()
{
    //创建多进程
    int i = 0;
    for (;i < num; i++)
    {
        pid_t id = fork();
        if (id == 0)
        {
            //child
            while (1)
            {
                printf("我是子进程，id: %d, ppid: %d\n", getpid(), getppid());
                sleep(1);
            }
        }
        else
        {
            //father
            printf("子进程创建成功, id: %d\n", id);
            sleep(1);
        }
    }
    
    while (1)
        printf("父进程结束, id: %d\n", getpid());

    return 0;
}
